from flask import Blueprint
from applications.system.resources.system_view import *

blueprint = Blueprint("system_api", __name__, url_prefix="/api")

from flask_restful import Api

api = Api(blueprint)

#######################日志管理缓存监控
# /monitor/cache
api.add_resource(
    SysMonitorCache,
    "/monitor/cache",
)

#######################系统监控服务监控
# /monitor/server
api.add_resource(
    SysMonitorServer,
    "/monitor/server",
)
#######################日志管理登录日志
api.add_resource(
    SysLogininForResource,
    "/monitor/logininfor/list",
    strict_slashes=False
)

#######################日志管理操作日志
api.add_resource(
    SysOperlogResource,
    "/monitor/operlog/list",
    strict_slashes=False
)

#######################通知公告
api.add_resource(
    SysNoticeResource,
    "/system/notice/list",
    strict_slashes=False
)
#######################参数设置

api.add_resource(
    InitPasswordResource,
    "/system/config/configKey/<path:key>"
)

api.add_resource(
    SysConfigResource,
    "/system/config/list",
    "/system/config",
    "/system/config/<path:id>",
    strict_slashes=False
)

#######################字典管理
# system/dict/data/list?pageNum=1&pageSize=10&dictType=test
# 添加字典的值
api.add_resource(
    SysDictDatumResource,
    "/system/dict/data/list",
    "/system/dict/data",
    "/system/dict/data/<path:id>",
    strict_slashes=False
)

# 刷新缓存
# /system/dict/type/refreshCache
api.add_resource(
    SysDictRefreshCache,
    "/system/dict/type/refreshCache"
)

api.add_resource(
    SysDictResource,
    "/system/dict/type/list",
    "/system/dict/type",
    "/system/dict/type/<path:id>",
    strict_slashes=False
)

#######################岗位管理

api.add_resource(
    SysPostResource,
    "/system/post/list",
    "/system/post",
    "/system/post/<path:id>",
    strict_slashes=False
)

#######################部门管理
# /system/dept/list/exclude/113
api.add_resource(
    SysDeptExcludeResource,
    "/system/dept/list/exclude/<path:id>"
)

api.add_resource(
    SysDeptResource,
    "/system/dept/list",
    "/system/dept",
    "/system/dept/<path:id>",
    strict_slashes=False
)
#######################菜单管理


# /system/menu/4

api.add_resource(
    SysMenuResource,
    "/system/menu/list",
    "/system/menu",
    "/system/menu/<path:id>",
    strict_slashes=False
)
#######################角色分割线start
# /system/role/authUser/cancelAll?roleId=11&userIds=1,2
# 角色添加用户,取消授权多个用户到角色
api.add_resource(
    SysRoleCancelAll,
    "/system/role/authUser/cancelAll"
)

# /system/role/authUser/selectAll?roleId=11&userIds=1
# 角色添加用户,授权多个用户到角色
api.add_resource(
    SysRoleSelectAll,
    "/system/role/authUser/selectAll"
)

# 角色下，用户添加，授权单个用户
# /system/role/authUser/cancel
api.add_resource(
    SysRoleAuthUserCancel,
    "/system/role/authUser/cancel"
)

# 角色添加,未关联用户列表
# /system/role/authUser/unallocatedList?pageNum=1&pageSize=10&roleId=11&userName=admin&phonenumber=15827325743
api.add_resource(
    SysRoleUnAllocatedList,
    "/system/role/authUser/unallocatedList"
)

# 角色添加,已关联用户列表
# /system/role/authUser/allocatedList?pageNum=1&pageSize=10&roleId=11&userName=admin&phonenumber=15827325743
api.add_resource(
    SysRoleAllocatedList,
    "/system/role/authUser/allocatedList"
)

# /system/role/dataScope
api.add_resource(
    SysRoleDataScope,
    "/system/role/dataScope",
)

# /system/dept/roleDeptTreeselect/5
api.add_resource(
    SysRoleDeptTreeSelect,
    "/system/dept/roleDeptTreeselect/<path:id>",
)

# /system/menu/roleMenuTreeselect/3
api.add_resource(
    SysRoleMenuTreeSelect,
    "/system/menu/roleMenuTreeselect/<path:id>",
)

# /system/menu/treeselect
api.add_resource(
    SysRoleTreeSelect,
    "/system/menu/treeselect"
)

# 角色启用停止状态修改
# /system/role/changeStatus
api.add_resource(
    SysRoleChangeStatus,
    "/system/role/changeStatus"
)

# /system/role/list?pageNum=1&pageSize=10
api.add_resource(
    SysRoleResource,
    "/system/role/list",
    "/system/role",
    # "/system/role/",
    "/system/role/<path:id>",
    strict_slashes=False
)

#######################角色管理

api.add_resource(DataTypeResource, "/system/dict/data/type/<path:dict_type>", endpoint="DataTypeResource")
api.add_resource(TreeSelectResource, "/system/dept/treeselect", endpoint="TreeSelectResource")
# 导入导出文件
# /system/user/export
api.add_resource(
    SysUserExport,
    "/system/user/export"
)

# system/user/importData?updateSupport=0
api.add_resource(
    SysUserImportData,
    "/system/user/importData"
)
# system/user/importTemplate
api.add_resource(
    SysUserImportTemplate,
    "/system/user/importTemplate"
)
# 分配角色
# system/user/authRole/11
# system/user/authRole?userId=11&roleIds=1,2
api.add_resource(
    SysUserAuthRoleResource,
    "/system/user/authRole/<path:id>",
    "/system/user/authRole"
)

# 修改密码
api.add_resource(
    SysUserResetPwdResource,
    "/system/user/resetPwd"
)

# 用户管理
api.add_resource(
    SysUserResource,
    "/system/user/list",
    "/system/user",
    "/system/user/",
    "/system/user/<path:id>",
    # endpoint="SysUserResource",
    # strict_slashes=False
)

api.add_resource(

    SysUserProfileResource,
    "/system/user/profile"
)

api.add_resource(
    SysUserProfileUpdatePwdResource,
    "/system/user/profile/updatePwd"
)

api.add_resource(
    SysUserChangeStatusResource,
    "/system/user/changeStatus",
    endpoint="SysUserChangeStatusResource")

api.add_resource(
    LoginResource,
    "/login"
)

api.add_resource(
    GetInfoResource,
    "/getInfo"
)

api.add_resource(
    RegisterResource,
    "/register"
)

api.add_resource(
    LoginOutResource,
    "/logout"
)

api.add_resource(
    CaptchaImageResource,
    "/captchaImage"
)

api.add_resource(
    GetRoutersResource,
    "/getRouters"
)
